/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package db;

import java.util.ArrayList;
import java.util.List;
import libCore.config.Config;
import share.PGHelper;

/**
 *
 * @author Salm
 */
class MultiRedisImpl /*implements MultiRedis*/ {
//    private static final String CONF_SECTION = "multi-redis";
//    private List<Redis> redisInsts;
//
//    public MultiRedisImpl()
//    {
//        List<Redis> insts = initInstances();
//        initRedis(insts);
//    }
//
//    private List<Redis> initInstances() {
//        int nInst = PGHelper.toInt(Config.getParam(CONF_SECTION, "num_inst"));
//        int maxActive = Integer.valueOf(Config.getParam(CONF_SECTION, "max_active"));
//        int maxIdle = Integer.valueOf(Config.getParam(CONF_SECTION, "max_idle"));
//        int maxWait = Integer.valueOf(Config.getParam(CONF_SECTION, "max_wait"));
//        int timeOut = Integer.valueOf(Config.getParam(CONF_SECTION, "timeout"));
//        
//        List<Redis> insts = new ArrayList(nInst);
//        for (int i = 1; i <= nInst; i++) {
//            String host = Config.getParam(CONF_SECTION, "host_" + i);
//            int port = Integer.valueOf(Config.getParam(CONF_SECTION, "port_" + i));
//            String password = Config.getParam(CONF_SECTION, "pass_" + i);
//            int db = Integer.valueOf(Config.getParam(CONF_SECTION, "database_" + i));
//            
//            insts.add(new JedisAdapter(JedisPoolFactory.create(host, port,
//                timeOut, password, db, maxActive, maxIdle, maxWait)));
//        }
//        
//        return insts;
//    }
//
//    private void initRedis(List<Redis> insts) {
//        String conf = Config.getParam(CONF_SECTION, "indexes");
//        String[] indexConfs = conf.trim().split(",");
//        redisInsts = new ArrayList(indexConfs.length);
//        for (String idxConf : indexConfs) {
//            String[] orderConfs = idxConf.split("-");
//            Redis[] arrRedis = new Redis[orderConfs.length];
//            for (int i = 0; i < orderConfs.length; i++) {
//                int index = Integer.parseInt(orderConfs[i]);
//                arrRedis[i] = insts.get(index - 1);
//            }
//            
//            redisInsts.add(new MultiRedisAdapter(arrRedis));
//        }
//     }
//    
//    @Override
//    public Redis Redis()
//    {
//        return redisInsts.get(0);
//    }
//    
//    @Override
//    public Redis Redis(int idx)
//    {
//        return redisInsts.get(idx);
//    }
}
